package hn.cch.microservice.service_provider_multi_param.controller;

import hn.cch.microservice.service_provider_multi_param.entity.User;
import hn.cch.microservice.service_provider_multi_param.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    @Autowired
    private UserRepository userRepository;

    @GetMapping(value = "/{id}")
    public User user(@PathVariable Long id){
        return userRepository.findOne(id);
    }


    @GetMapping("/get")
    public User get(User user) {
        return userRepository.findUserByAccountAndName(user.getAccount(), user.getName());
    }

    @PostMapping("/post")
    public User post(@RequestBody User user) {
        return userRepository.findUserByAccountAndName(user.getAccount(), user.getName());
    }

}
